package cn.itutu.demo.junit;
import org.junit.*;
import org.junit.runner.RunWith;
import org.junit.runners.BlockJUnit4ClassRunner;

import static org.junit.Assert.assertEquals;

/**
 * Created by itutu on 2018/4/13.
 * Description:
 * 1.@Test方法写法
 * 2.Fixture方法执行顺序
 */
@RunWith(BlockJUnit4ClassRunner.class)
public class Junit4Demo {
    Calculator calculator = new Calculator();
    @BeforeClass
    public static void initCalculator(){
        System.out.println(System.currentTimeMillis() + "  @BeforeClass:测试用例开始执行");
    }
    @Before
    public void testStart(){
        System.out.println(System.currentTimeMillis() + "  @Before");
    }
    @After
    public void testEnd(){
        System.out.println(System.currentTimeMillis() + "  @After");
    }
    @AfterClass
    public static void endTest(){
        System.out.println(System.currentTimeMillis() + "  @AfterClass:测试用例全部执行完毕");
    }

    @Test
    public void testAdd(){
        System.out.println(System.currentTimeMillis() + "  @Test测试方法 testAdd");
        assertEquals(3, calculator.add(1,2));
    }
    @Test
    public void testSub(){
        System.out.println(System.currentTimeMillis() + "  @Test测试方法 testSub");
        assertEquals(3, calculator.subtraction(5,2));
    }

}
